package com.shoujifeng.snowmusic.entity;

import android.content.Context;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;

public class AnimaAccess
{
	private Context mContext;

	public AnimaAccess(Context context)
	{
		mContext = context;
		//
	}

	//aaaa
	/**
	 * 移动
	 * 
	 * @param fromX
	 * @param toX
	 * @param fromY
	 * @param toY
	 * @param nTime
	 * @return
	 */
	public AnimationSet moveAnimation(float fromX, float toX, float fromY,
			float toY, int nTime, boolean after)
	{
		AnimationSet animationSet = new AnimationSet(true);
		TranslateAnimation translateAnimation = new TranslateAnimation(fromX,
				toX, fromY, toY);

		translateAnimation.setDuration(nTime);
		animationSet.addAnimation(translateAnimation);
		animationSet.setFillAfter(after);
		return animationSet;
	}

	/**
	 * 移动
	 * 
	 * @param fromX
	 * @param toX
	 * @param fromY
	 * @param toY
	 * @param nTime
	 * @return
	 */
	public AnimationSet moveAnimationSelf(float fromX, float toX, float fromY,
			float toY, int nTime, boolean after)
	{
		AnimationSet animationSet = new AnimationSet(true);
		TranslateAnimation translateAnimation = new TranslateAnimation(
				Animation.RELATIVE_TO_SELF, fromX, Animation.RELATIVE_TO_SELF,
				toX, Animation.RELATIVE_TO_SELF, fromY,
				Animation.RELATIVE_TO_SELF, toY);

		translateAnimation.setDuration(nTime);
		animationSet.addAnimation(translateAnimation);
		animationSet.setFillAfter(after);
		return animationSet;
	}

	/**
	 * 透明度
	 * 
	 * @param from
	 * @param to
	 * @param nTime
	 * @param after
	 * @return
	 */
	public AnimationSet alphaAnimation(float from, float to, float fromX,
			float toX, float fromY, float toY, int nTime, boolean after)
	{
		AnimationSet animationSet = new AnimationSet(true);
		AlphaAnimation alphaAnimation = new AlphaAnimation(from, to);
		TranslateAnimation translateAnimation = new TranslateAnimation(
				Animation.RELATIVE_TO_SELF, fromX, Animation.RELATIVE_TO_SELF,
				toX, Animation.RELATIVE_TO_SELF, fromY,
				Animation.RELATIVE_TO_SELF, toY);

		alphaAnimation.setDuration(nTime);
		translateAnimation.setDuration(nTime);
		animationSet.addAnimation(alphaAnimation);
		animationSet.addAnimation(translateAnimation);
		animationSet.setFillAfter(after);
		return animationSet;
	}
}
